﻿using System;
using System.IO.IsolatedStorage;
using System.Windows;
using System.Windows.Controls;

namespace RentAWorker.RIA
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            PresentationModel pm = new PresentationModel();
            this.DataContext = pm;

			//pm.OnUnPersist(IsolatedStorageSettings.ApplicationSettings);
            Application.Current.Exit += Current_Exit;
		}

        void Current_Exit(object sender, EventArgs e)
        {
            Application.Current.Exit -= Current_Exit;

            ((PresentationModel)this.DataContext).OnPersist(IsolatedStorageSettings.ApplicationSettings);
            IsolatedStorageSettings.ApplicationSettings.Save();
        }
    }
}
